package com.cd.javacxy.common.model.enums;


import org.apache.http.HttpStatus;

/**
 * @author UserC
 */

public enum ResponseCode {
    /**
     * 200
     */
    SUCCESS(200, "请求成功"),

    NOPERMISSION(403, "没有权限"),

    BUSSINESSERROR(415, "业务异常"),

    CODEERROR(425, "验证码错误"),

    SERVERERROR(500, "服务器错误"),

    LOGINTIMEOUT(401, "登录超时"),
    BAD_REQUEST(400,"参数错误");
    private final int code;
    private final String desc;

    ResponseCode(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    public static ResponseCode getResponseByCode(Integer code) {
        for (ResponseCode rc : ResponseCode.values()) {
            if (rc.code == code) {
                return rc;
            }
        }
        return null;
    }
}
